function displayDate(){
	document.getElementById('demo').innerHTML = Date();
}

// 使用 JS 分配事件
function showMessage(){
	document.getElementById('demoTwo').innerHTML = '通过 JS 添加事件';
}
document.getElementById('myBtn').onclick = function(){
	showMessage();
}

//onload 处理 cookie
function checkCookies(){
	if (navigator.cookieEnabled == true) {
// 		alert('已启用 cookie');
		console.log('已启用 cookie');
	}else{
		console.log('未启用 cookie');
// 		alert('未启用 cookie');
	}
}

// onchnage 
function myFunction(){
	var x = document.getElementById("fname");
	x.value = x.value.toUpperCase();
}

// onmouseover 和 onmouseout
function mOver(obj){
	obj.innerHTML = "谢谢";
	obj.style.color = "blue";
}

function mOut(obj){
	obj.innerHTML = "把鼠标移动上面";
	obj.style.color = "white";
}

// onmousedown 和 onmouseup
function mDown(obj){
	obj.innerHTML = "请释放鼠标按钮";
}

function mUp(obj){
	obj.innerHTML = "请按下鼠标按钮";
}


// 使用对象构造器来构造对象
function person(firstname, lastname, age, eyecolor){
	this.firstname = firstname;
	this.lastname = lastname;
	this.age = age;
	this.eyecolor = eyecolor;

	this.changeName = changeName;
	function changeName(name){
		this.lastname = name;
	}
}

var xiaoMing = new person("xiaoMing", "wang", 18, "green");
console.log(xiaoMing);
console.log(xiaoMing.firstname);
xiaoMing.changeName("zhangShan");
console.log(xiaoMing.lastname);

for(x in xiaoMing){
	console.log(xiaoMing['changeName']);
}

